package com.x.Part2_Exception类.编译时异常;

import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


/**
 * ClassName: Test
 * Package: IntelliJ IDEA
 * Description:编译时异常举例
 * Written by HanXu
 * Create 2024.03.17 15:30
 */
public class Test1 {


    @Test
    //FileNotFoundException
    //IOException
    public void test1() throws IOException, FileNotFoundException {//预处理，不处理编译不让过
        File file = new File("D:/My code/111.txt");
        FileInputStream fis = new FileInputStream(file);//java.io.FileNotFoundException
        int data = fis.read();//java.io.IOException
        while(data !=-1){
            System.out.print((char)data);
            data = fis.read();//java.io.IOException
        }
        fis.close();//java.io.IOException
    }
}
